package cn.zwxky.android.staff.Approve;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.zgscwjm.lsfbbasetemplate.Event.LsfbEvent;
import com.zgscwjm.lsfbbasetemplate.adapter.CommonRecycAdapter;
import com.zgscwjm.lsfbbasetemplate.adapter.ViewHolderRecyc;

import java.util.List;

import cn.zwxky.android.staff.R;
import cn.zwxky.android.staff.Utils.URLString;

/**
 * Created by Administrator on 2017/4/6 0006.
 */

public class TaskAdapter extends CommonRecycAdapter<TaskBean.ListBean> {
    private Context mContext;
    public TaskAdapter(Context context, List<TaskBean.ListBean> list, int layoutId) {
        super(context, list, layoutId);
        mContext=context;
    }

    @Override
    public void convert(ViewHolderRecyc holder, final TaskBean.ListBean model) {

        holder.setImg(R.id.item_leave_img_head, URLString.IMG_URL+model.getImg(),R.mipmap.img_my_details_head);
        holder.setText(R.id.aty_text_name,model.getName());
        holder.setText(R.id.aty_text_phone,model.getTel());
        holder.setText(R.id.aty_text_gongsi,model.getCompany());
        holder.setText(R.id.aty_text_title,model.getProname());
        if (model.getContent().isEmpty()){
            holder.setVisible(R.id.aty_text_beizhu,false);
        }else {
            holder.setVisible(R.id.aty_text_beizhu,true);
            holder.setText(R.id.aty_text_beizhu, model.getContent());
        }
        holder.setText(R.id.aty_text_type,model.getCla_name());

        if (model.getMsg().isEmpty()){
            holder.setVisible(R.id.item_leave_text_reject,false);
        }else {
            holder.setVisible(R.id.item_leave_text_reject,true);
            holder.setText(R.id.item_leave_text_reject,"驳回原因："+model.getMsg());
        }

        TextView textView=holder.getView(R.id.aty_text_status);
        //0驳回，1市场部，2总经理，3经营部
         if (model.getStatus().equals("0")) {
             holder.setText(R.id.aty_text_status, "驳回");
             textView.setTextColor(mContext.getResources().getColor(R.color.label_red));
         }else if (model.getStatus().equals("4")) {
             holder.setText(R.id.aty_text_status, "归档");
             textView.setTextColor(mContext.getResources().getColor(R.color.label_green));
         }else {
             holder.setText(R.id.aty_text_status, "审批中");
             textView.setTextColor(mContext.getResources().getColor(R.color.label_yellow));
         }

        holder.setOnclick(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                TaskClikEvent event=new TaskClikEvent();
                  event.setData(model.getId());
                LsfbEvent.getInstantiation().post(event);
            }
        });

    }
}
